package cn.ljy.mes.web.controller.backstage.wms.warehouse;


import cn.ljy.authority.web.controller.backstage.BaseBackstageController;
import cn.ljy.common.model.result.ResponseData;
import cn.ljy.mes.model.WmsMaterialInventoryDetail;
import cn.ljy.mes.model.query.WmsMaterialInventoryDetailQuery;
import cn.ljy.mes.model.vo.WmsMaterialInventoryDetailRelocationVo;
import cn.ljy.mes.service.WmsMaterialInventoryDetailService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "后台物料批次模块")
@RestController
@RequestMapping(value = "/backstage/wms/materialInventoryDetail")
public class WmsMaterialInventoryDetailController extends BaseBackstageController<WmsMaterialInventoryDetail, WmsMaterialInventoryDetailQuery,String> {

    @Autowired
    private WmsMaterialInventoryDetailService baseService;

    @Override
    protected String getAuthorityPrefix() {
        return "wms:materialinventorydetail"; // 定义模块权限前缀
    }

//    @GetMapping("/all")
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:query')")
//    @Override
//    protected ResponseData query(WmsMaterialInventoryDetailQuery query) {
//        return super.query(query);
//    }
//
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:query')")
//    @Override
//    public ResponseData query(Integer page, Integer pageSize, WmsMaterialInventoryDetailQuery query){
//        return super.query(page,pageSize,query);
//    }
//
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:add')")
//    @Override
//    protected ResponseData add(@Validated({AddWorkValidation.class}) @RequestBody WmsMaterialInventoryDetail wmsMaterialInventoryDetail) {
//        return super.add(wmsMaterialInventoryDetail);
//    }
//
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:query')")
//    @Override
//    protected ResponseData get(@PathVariable String id) {
//        return super.get(id);
//    }
//
//
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:edit')")
//    @Override
//    public ResponseData edit(@Validated({UpdateWorkValidation.class}) @RequestBody WmsMaterialInventoryDetail wmsMaterialInventoryDetail){
//        return super.edit(wmsMaterialInventoryDetail);
//    }
//
//    @PreAuthorize("hasAuthority('wms:materialinventorydetail:del')")
//    @Override
//    public ResponseData deletes(String[] ids){
//        return super.deletes(ids);
//    }


    //移库操作
    @PutMapping("/relocation")
    @PreAuthorize("hasAuthority('wms:materialinventorydetail:relocation')")
    public ResponseData relocation(@RequestBody WmsMaterialInventoryDetailRelocationVo materialInventoryDetailRelocationVo){
        baseService.relocation(materialInventoryDetailRelocationVo.getMaterialInventoryDetailOfSource(),materialInventoryDetailRelocationVo.getMaterialInventoryDetailOfTarget());
        return ResponseData.success(null);
    }

}
